package com.polaris.live.adapter

import android.view.View
import com.bumptech.glide.Glide
import com.polaris.live.common.R
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterFollowingBinding
import com.polaris.live.im.sfs.bean.live.ext.UserBasicVo
import com.polaris.live.utils.image.ImageUtils
import com.polaris.live.utils.image.normal
import com.polaris.live.widget.avatar.FrameImageUtils

/**
 * FollowAdapter
 *
 * @author Created by 半仙 on 2023/9/4/004 12:03
 */
class FollowAdapter : BaseBindingAdapter<AdapterFollowingBinding, UserBasicVo>() {

    override fun convert(holder: VBViewHolder<AdapterFollowingBinding>, item: UserBasicVo) {
        holder.vb.apply {
            Glide.with(context).load(ImageUtils.imgPathSmall(item.avatar)).normal().into(followItemHead)
            followItemNickName.text = item.nickname
            followItemNickName.setNicknameColor(
                item.nicknameColor,
                R.color.color_202028
            )
            avFv.setFrameImage(FrameImageUtils.urlToFrameImageBean(item.avatarFrame))
            myLevel.setRichCharmBySexLevel(
                item.sex,
                item.richs,
                item.charms
            )
            vipView.setVipLevel(item.vipLevel)
            if (item.country?.isBlank() == true) {
                followItemCountry.visibility = View.GONE
            } else {
                followItemCountry.visibility = View.VISIBLE
                followItemCountry.setCountry(item.country)
            }
        }
    }

}